package org.dromara.common.job.client.config;

import org.dromara.common.job.client.config.properties.PowerJobClientProperties;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import tech.powerjob.client.PowerJobClient;

/**
 * pj客户端配置
 *
 * @author Chan
 */
@AutoConfiguration
@EnableConfigurationProperties(PowerJobClientProperties.class)
public class PowerJobClientConfig {

    /**
     * 初始化PowerJobClient
     */
    @Bean(name = "powerJobClient")
    public PowerJobClient initPowerJobClient(PowerJobClientProperties properties) {
        PowerJobClient client = new PowerJobClient(properties.getServerAddress(), properties.getAppName(), properties.getPassword());
        return client;
    }
}
